﻿using RockBus.Hosting.Interfaces;
using RockBus.Initialization.Interfaces;
using RockBus.Logging.Interfaces;
using RockBus.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace RockBus.Hosting
{
    public class ServiceHostInitialization : IInitialization
    {
        public ServiceHostInitialization(ILogger logger, IServiceHostManager serviceHostManager)
        {
            this.Logger = logger;
            this.ServiceHostManager = serviceHostManager;
        }

        private ILogger Logger { get; set; }

        private IServiceHostManager ServiceHostManager { get; set; }

        public void Initialize()
        {
            this.Logger.LogInfo(MethodBase.GetCurrentMethod(), "Opening static service hosts.");

            // Create and open the static host for the CbrService
            var staticServiceHost = new StaticServiceHost<CbrService>(this.Logger);
            staticServiceHost.Open();
            this.ServiceHostManager.RegisterStaticServiceHost(staticServiceHost);

            // Create and open the static host for the MonitoringService
            //var monitoringServiceHost = new StaticWebServiceHost(this.Logger, typeof(RockBus.Services.MonitoringService));
            //monitoringServiceHost.Open();
            //this.ServiceHostManager.RegisterStaticServiceHost(monitoringServiceHost);

            // Create and open the static host for the MonitoringService
            //var configurationServiceHost = new StaticWebServiceHost(this.Logger, typeof(RockBus.Services.ConfigurationService));
            //configurationServiceHost.Open();
            //this.ServiceHostManager.RegisterStaticServiceHost(configurationServiceHost);
        }
    }
}
